package com.qcc.cashier;

import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.KeyEvent;

import com.facebook.react.ReactActivity;
import com.qcc.cashier.pos.PosHelper;

public class MainActivity extends ReactActivity {
    HomeReceiver innerReceiver;
    /**
     * Returns the name of the main component registered from JavaScript. This is used to schedule
     * rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "CashierApp";
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        innerReceiver = new HomeReceiver();
        IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        registerReceiver(innerReceiver, intentFilter);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onDestroy() {
        unregisterReceiver(innerReceiver);
        super.onDestroy();
        PosHelper.stopReadCard();
    }

    @Override
    protected void onPause() {
        super.onPause();
        PosHelper.stopReadCard();
    }

    @Override
    public void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
//        PosHelper.getCardReader().sendMessageValidNFC(intent);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }

}
